<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>

<jsp:useBean id="nowDate" class="java.util.Date" />
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>销售订单完结编辑</title>
	<!-- import css and js --> 
	<%@ include file="/common/metaInput.jsp" %>  
	<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript" src="${ctx}/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
var basic_Url="${ctx}/logic/sales";
var grid;
$(function(){
	
	//表格结构
	grid = $("#table1").ligerGrid({
        columns: [{ display: 'ID', name: 'id', width: 1 , hide:true},
                  { display: '产品id', name: 'zd006MaterialsId', width: 1 , hide:true},//使用selecturl时必须设置该属性
                  { display: '<font color="gray">产品编码</font>', name: 'zd007MaterialsCode',  width: 100},
				  { display: '<font color="gray">产品名称</font>', name: 'zd008MaterialsName', width: 100 },
				  { display: '产品型号<font color="red">*</font>', name: 'zd010MaterialsModel', width: 100,editor: { type: 'text'}},
				  { display: '产品尺寸<font color="red">*</font>', name: 'zd038MaterialsSize', width: 100,editor: { type: 'text'}},
				  { display: '产品颜色<font color="red">*</font>', name: 'zd041MaterialsColor', width: 60,editor: { type: 'text'}},
				  { display: '产品材质<font color="red">*</font>', name: 'zd042MaterialsQuality', width: 60,editor: { type: 'text'}},
				  { display: '计量单位<font color="red">*</font>', name: 'zd012MaterialsUnit', width: 60,editor: { type: 'text'}},
				  { display: '数量<font color="red">*</font>', name: 'zd013Quantity', width: 80 },
				  { display: '单价', name: 'zd017Price', width: 80},
				  { display: '金额', name: 'zd028SumMoney', width: 110},
                  { display: '产品描述', name: 'zd036MaterialsDescription', width: 150}
                  ],
                  enabledEdit: true,
                  usePager: true,pageSize:1000,pageSizeOptions:[1000],
                  parms:[{ name : 'id' , value : '${sales.id}'}],
                  url : basic_Url+"/finishSaleBillsItem.do",
                  width: "100%", height:'90%', checkbox: true,
     });
	
	//表单提交触发
	$("#inputForm").validate({			   
	onsubmit: true,
	 /*执行ajaxsubmit  */ 
    submitHandler: function(editform) {
        try{			    		
            url =  basic_Url+"/endBill.do?id="+$("#id").val();
            var api = frameElement.api;
        	var W = api.opener;
            getReturnMessage(url,"inputForm",W.searchAP);
        }catch(e){alert(e);}
    }
	});
	function selectBillSales(){
		getDG().dialog(
				{
					title : '选择销售订单',
					width : 650,
					height : 350,
					content : 'url:' + sys_context
							+ '/public/windowalert/salescode.do',    
					lock : true,
					max : true,
					min : true,
					ok : function() {
						var rows = this.content.getSelected();
						if (rows != null) {
							$(rows).each(function() {
								$("#zd012CustomerCode").val(this.zd005CustomerCode);
								$("#zd012CustomerName").val(this.zd006CustomerName);
								$("#zd002OriCode").val(this.zd001FormCode);
								$("#zd003PiCode").val(this.zd002PiCode);
								$("#zd013CurrencyCode").val(this.zd014CurrencyCode);
								$("#zd013CurrencyName").val(this.zd014CurrencyName);
								$("#zd014ExchangeRate").val(this.zd015ExchangeRate);
								$("#zd015SalesMan").val(this.zd022SalesMan);
								var url=basic_Url+"/gridBomItems.do?id="+this.id;
								multipleSearch("#dataGrid1",true,"",url);
							});
						}
						this.content.Close();
						return false;
					},
					cancelVal : '关闭',
					cancel : true
				}).zindex(); 
	}
</script>
</head>
<body>
<form id="inputForm" action="" method="post">
<input type="hidden" id="id" name="id" value="${sales.id}"/>
 <div class="pageContent" >
    <div class="panel">
         <table class="TableBlock" align="center">
   		            <tr>
	                    <td nowrap="nowrap" width="20%">销售订单编号:</td>
	   		            <td>
	   		                <input type="text" style="width:200px;" id="zd001FormCode" name="zd001FormCode" value="${sales.zd001FormCode}"  readonly="readonly"/>
	   		            	<input value='...' onclick="selectBillSales()" />
	   		            </td>
   		            	<td nowrap="nowrap" width="20%">销售类型:</td>
		   		            <td colspan="3">
		   		            <input type="radio" id="zd026WithSingle" name="zd026WithSingle" value="1" <c:if test="${sales.zd026WithSingle==1||sales.zd026WithSingle==null}"> checked="checked"</c:if>/>普通&nbsp;
		              		<input type="radio" id="zd026WithSingle" name="zd026WithSingle" value="0" <c:if test="${sales.zd026WithSingle==0}"> checked="checked"</c:if>/>加单&nbsp;
		              	</td>
   		            </tr>
   		           <tr>
   		           		<td nowrap="nowrap" width="20%">PI编号:</td>
   		                <td>
   		                	<input type="text" style="width:200px;" id="zd002PiCode" name="zd002PiCode" onchange="changePiCode()" value="${sales.zd002PiCode}" class="inp_width_98p"/>
   		                </td>
                   		<td nowrap="nowrap" width="20%">产品类型:</td>
   		                <td>
   		                	<input type="text" readonly="readonly" id="zd028SaleType" name="zd028SaleType" value=<c:if test='${sales.zd028SaleType=="BT"}' >套床</c:if><c:if test='${sales.zd028SaleType=="MT"}' >床垫</c:if> />
   		                 </td>
   		           </tr>
   		           <tr>
   		            	<td nowrap="nowrap">客户编号:</td>
   		           		<td>
   		           			<input type="text" style="width:200px;" id="zd005CustomerCode" name="zd005CustomerCode" value="${sales.zd005CustomerCode}" readonly="readonly" class=" required" />
   		           		</td>
   		           		<td nowrap="nowrap">客户名称:</td>
   		           		<td>
   		                 <input type="text" style="width:200px;" id="zd006CustomerName" readonly="readonly" name="zd006CustomerName" value="${sales.zd006CustomerName}" class="required"></input>
   		                 </td>
   		           		
   		           </tr>
   		           <tr>
   		           		<td nowrap="nowrap">建单时间:</td>
   		           		<td><input type="text" style="width:200px;" id="bizCreatorDate" name="bizCreatorDate" class="Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" class="Wdate" value="<fmt:formatDate value="${sales.bizCreatorDate}" pattern="yyyy-MM-dd" type="both" />"  readonly="readonly"></input></td>
   		           		<td nowrap="nowrap">交货时间:</td>
   		           		<td><input type="text" style="width:200px;" id="zd017DeliveryDate" name="zd017DeliveryDate" class="Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" class="Wdate" value="<fmt:formatDate value="${sales.zd017DeliveryDate}" pattern="yyyy-MM-dd" type="both" />"  readonly="readonly"></input></td>
   		           </tr>
   		           <tr>
   		            	<td nowrap="nowrap">币种:</td>
   		           		<td><input type="text" style="width:200px;" id="zd014CurrencyName" name="zd014CurrencyName" value="${sales.zd014CurrencyName}" readonly="readonly"></input>
   		           		</td>
   		           		<td nowrap="nowrap">汇率:</td>
   		           		<td>
   		                 <input type="text" style="width:200px;" id="zd015ExchangeRate" readonly="readonly" name="zd015ExchangeRate" value="${sales.zd015ExchangeRate}"></input>
   		                 </td>
   		           		
   		           </tr>
   		           <tr>
   		           		<td nowrap="nowrap">业务员:</td>
   		           		<td><input type="text" style="width:200px;" readonly="readonly" id="zd022SalesMan" name="zd022SalesMan" value="${sales.zd022SalesMan}" class="required"></input>
   		           		</td>
                    	<td nowrap="nowrap">备注:</td>
   		                <td>
   		                	<input type="text" id="zd023Remark" style="width:98%" name="zd023Remark" value="${sales.zd023Remark}" />
   		                </td>
   		           </tr>
   		           <tr>
   		           		<td>附件</td>
   		           		<td>
   		           			<input type="file" id="filePath" name="filePath" value="" />
   		           		</td>
   		           		<td colspan="3">
   		           			<c:forEach items="${upFiles }" var="varF" varStatus="varSt">
   		           				<input type="hidden" id="fileId_${varSt.index }" value="${varF.id }"/>
   		           				<input type="hidden" id="fileName_${varSt.index }" value="${varF.fileName }"/>
   		           				<a class="add" onclick="downUploadFile('${varSt.index }','${varF.diskPath}')"><span>${varF.fileName }</span><span></span></a>
   		           			</c:forEach>
   		           		</td>
					</tr>
                </table>
                <div id="table1"> </div>               
         </div>
         <div class="formBar">
	        <ul>
		        <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btn_fb_submit" >完结</button></div></div></li>
		       <li><div class="button"><div class="buttonContent"><button type="button" onclick="CloseDialog()">关闭</button></div></div></li>
	        </ul>
        </div>    
    </div>
</form>
</body>
</html>
